#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void reverse(char* left, char* right)
{	
	while (left < right)
	{
		char tmp = *left;
		*left = *right;
		*right = tmp;
		right--;
		left++;
	}
}

int main()
{
	char arr[100] = { };
	gets_s(arr);
	int len=strlen(arr);
	reverse(arr,arr+len-1);
	char* start = arr;
	while (*start)
	{
		char* end = start;
		while (*end != ' ' && *end != '\0')
			end++;
		reverse(start, end-1);
		if (*end == ' ')
			start = end + 1;
		else
			start = end;
	}
	printf("%s\n", arr);
	system("pause");
	return 0;
}
